package com.ruoyi.web.controller.operation;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.GwSystemConfig;
import com.ruoyi.system.service.IGwSystemConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 系统运营配置Controller
 * 
 * @author ruoyi
 * @date 2025-05-08
 */
@Api(description = "平台运营管理-系统配置管理")
@RestController
@RequestMapping("/system/operationSystemConfig")
public class GwSystemConfigController extends BaseController
{
    @Autowired
    private IGwSystemConfigService gwSystemConfigService;

    /**
     * 查询系统运营配置列表
     */
    @ApiOperation("查询系统运营配置列表-分页")
    @GetMapping("/list")
    public TableDataInfo list(GwSystemConfig gwSystemConfig)
    {
        startPage();
        List<GwSystemConfig> list = gwSystemConfigService.selectGwSystemConfigList(gwSystemConfig);
        return getDataTable(list);
    }

    /**
     * 导出系统运营配置列表
     */
    @PreAuthorize("@ss.hasPermi('system:operationSystemConfig:export')")
    @Log(title = "系统运营配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GwSystemConfig gwSystemConfig)
    {
        List<GwSystemConfig> list = gwSystemConfigService.selectGwSystemConfigList(gwSystemConfig);
        ExcelUtil<GwSystemConfig> util = new ExcelUtil<GwSystemConfig>(GwSystemConfig.class);
        util.exportExcel(response, list, "系统运营配置数据");
    }

    /**
     * 获取系统运营配置详细信息
     */
    @ApiOperation("查询系统运营配置详情")
    @PreAuthorize("@ss.hasPermi('system:operationSystemConfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(gwSystemConfigService.selectGwSystemConfigById(id));
    }

    /**
     * 新增系统运营配置
     */
    @ApiOperation("新增系统运营配置")
    @PreAuthorize("@ss.hasPermi('system:operationSystemConfig:add')")
    @Log(title = "系统运营配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GwSystemConfig gwSystemConfig)
    {
        return toAjax(gwSystemConfigService.insertGwSystemConfig(gwSystemConfig));
    }

    /**
     * 修改系统运营配置
     */
    @ApiOperation("修改系统运营配置")
    @PreAuthorize("@ss.hasPermi('system:operationSystemConfig:edit')")
    @Log(title = "系统运营配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GwSystemConfig gwSystemConfig)
    {
        return toAjax(gwSystemConfigService.updateGwSystemConfig(gwSystemConfig));
    }

    /**
     * 删除系统运营配置
     */
    @ApiOperation("删除系统运营配置")
    @PreAuthorize("@ss.hasPermi('system:operationSystemConfig:remove')")
    @Log(title = "系统运营配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(gwSystemConfigService.deleteGwSystemConfigByIds(ids));
    }

    /**
     * 获取系统运营配置详细信息
     */
    @ApiOperation("查询系统运营配置详情")
    @GetMapping(value = "/getSystemConfigInfo")
    public AjaxResult getSystemConfigInfo()
    {
        GwSystemConfig config = gwSystemConfigService.getSystemConfigInfo();
        return success(config);
    }
}
